import { ccs } from "../../util/services";
import { game } from "../control/game";
import { mapType } from "../gameType";
import { playerClass } from "./playerModel";


export class mapClass {

    mapData: mapType[] = null;

    constructor(data?: []) {
        this.mapData = data || ccs.dataMgr.gameJson["map"];
    }

    unlockMap(id: number, player: playerClass = game.playerMgr) {
        let map = this.mapData.find(val => val.id == id);
        let canUnlock = true;
        for(let val in map) {
            if(map[val] > player[val]){
                canUnlock = false;
            }
        }
        if(canUnlock) {
            map.isLock = false;
        }
        return false;
    }
    
}